﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Kooboo.Commerce.Contexts.ShopSettings;

namespace Kooboo.Commerce
{
    public static class ProductImageCommand
    {
        public static string ImageUrl(this IProductImage image, string folder, string size)
        {
            //return Configuration.AppRootPath.Replace("\\", "/") + Configuration.ImageFolderName + "/" + folder + "/" + size + "/" + image.Name;
            String imageFolder = Configuration.FindImageUrlBase(folder, size);
            return imageFolder + image.Name;
        }

        public static string ThumnailUrl(this IProductImage image, string folder)
        {
            var host = new ServiceHost();
            return image.ImageUrl(folder, host.GetShopSettings().ImageSettings.Thumbnail.Name);
        }

        public static string DetailUrl(this IProductImage image, string folder)
        {
            var host = new ServiceHost();
            return image.ImageUrl(folder, host.GetShopSettings().ImageSettings.Detail.Name);
        }

        public static string ListUrl(this IProductImage image, string folder)
        {
            var host = new ServiceHost();
            return image.ImageUrl(folder, host.GetShopSettings().ImageSettings.List.Name);
        }

        public static string CartUrl(this IProductImage image, string folder)
        {
            var host = new ServiceHost();
            return image.ImageUrl(folder, host.GetShopSettings().ImageSettings.Cart.Name);
        }
    }
}
